﻿using System.Windows.Forms;

namespace zielonka.co.uk.extensions.system.windows.forms.listbox
{
    //Description:	Adds an item to a listbox as the last item, and makes sure it is visible.
    /*
        ListBox1.AddToEnd( "foo" );
        ListBox1.AddToEnd( "bar" );
     */

    public static partial class ListboxExtensions
	{
        /**
        * <summary>Scrolls to the bottom of a TextBox.</summary>
        *
        * <remarks>The scroll occurs by moving the caret and scrolling to it;
        * therefore you shouldn't use this method if caret placement is
        * important in your application.</remarks>
        */
        public static void AddToEnd(this ListBox lb, object o)
        {
            lb.Items.Add(o);
            lb.TopIndex = lb.Items.Count - 1;
            lb.ClearSelected();
        }
	}
}
